package com.novel.frame.lgw;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

import com.mysql.fabric.xmlrpc.base.Array;
import com.novel.frame.lgw.Reptile.ChineseNumToArabicNumUtil;
import com.novel.frame.lgw.Reptile.Demo;
import com.novel.frame.lxf.FirstPage_Jpanel;
import com.novel.frame.lxf.Login_Panel;
import com.novel.frame.lxf.Register_Jpanel;
import com.novel.frame.wxl.ClickLaterFrame;
import com.novel.frame.wxl.ClickLaterFrame_click;
import com.novel.frame.wxl.RankingFrame;
import com.novel.frame.wxl.SearchFrame;
import com.novel.frame.yf.My_bookshelf;
import com.novel.frame.yf.Person_center;

/**
 * 小说阅读界面
 *
 */
public class NovelRead extends JFrame {
	private static final long serialVersionUID = 1L;
	private JScrollPane js_MainScreen;// 主滚动面板
	private JPanel jp_MainScreen;// 主面板
	private JPanel jp_north;// 北部面板
	private JLabel jl_readTitle;// 阅读面板标题
	private JLabel jl_readHomePage;// 转首页标签	
	private JLabel jl_cutOne;// 首页|书库 分割
	private JLabel jl_readBookRoom;// 转书库标签
	private JLabel jl_cutTwo;// 书库|排行 分割
	private JLabel jl_readRank;// 排行
	private JTextField jt_readSelect;// 阅读搜索框
	private JLabel jl_readSelect;// 搜索标签
	private JLabel jl_readLand;// 登入
	private JLabel jl_readRegister;// 注册

	private JPanel jp_center;// 中部面板
	private JLabel jl_position;// 当前位置
	private JScrollPane js_readDisplay;// 展示滚动面板
	private JPanel jp_readDisplay;// 展示面板
	private JTextArea jt_readNovel;// 展示文本框
	private JPanel jp_readmenu;// 菜单面板
	private JButton jb_readCatalog;// 阅读目录
	private JButton jb_readSetUp;// 阅读设置
	private JButton jb_readStackRoom;// 阅读书库
	private JButton jb_readPage;// 阅读书页
	private JButton jb_readTop;// 回顶
	private JButton jb_readLastChapter;// 上一章
	private JButton jb_readNextChapter;// 下一章

	 static int pn=0;
	
	 private  JLabel[] jl;
	 private  JButton[] jl_1;
	 private  JButton[]  jl_2;
	public NovelRead(String username,boolean flag,String bookname) {
		Dimension d = getToolkit().getScreenSize();
		setLayout(null);
		// 创建滚动面板
		js_MainScreen = new JScrollPane();
		js_MainScreen.setBounds(0, 0, d.width, d.height);
		js_MainScreen.getVerticalScrollBar().setUnitIncrement(20);
		add(js_MainScreen);
		// 创建主面板
		jp_MainScreen = new JPanel();
		jp_MainScreen.setPreferredSize(new Dimension(d.width, (int)(d.height*0.85)));
		jp_MainScreen.setBackground(Color.white);
		jp_MainScreen.setLayout(new BorderLayout());
		js_MainScreen.getViewport().add(jp_MainScreen);
		// 创建北部面板
		jp_north = new JPanel();
		jp_north.setPreferredSize(new Dimension(0, (int) (d.height * 0.08)));
		jp_north.setBackground(new Color(241, 241, 241));
		jp_north.setLayout(null);
		jp_MainScreen.add(BorderLayout.NORTH, jp_north);
		// 阅读（书海）标题
		jl_readTitle = new JLabel();
		ImageIcon im_readTitle = new ImageIcon(NovelRead.class.getResource("shuhai.png"));
		jl_readTitle.setIcon(im_readTitle);
		jl_readTitle.setBounds((int) (d.width * 0.11), (int) ((d.height * 0.08) * 0.1), im_readTitle.getIconWidth(),
				im_readTitle.getIconHeight());
		jp_north.add(jl_readTitle);
		// 转首页标签
		jl_readHomePage = new JLabel("首页");
		jl_readHomePage.setBounds(im_readTitle.getIconWidth() + (int) (d.width * 0.12) + 30,
				im_readTitle.getIconHeight() / 12, 40, (int) (d.height * 0.08));
		jl_readHomePage.setFont(new Font("宋体", Font.BOLD, 15));
		jl_readHomePage.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jl_readHomePage.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				new FirstPage_Jpanel(username,flag);
				dispose();
				
			}
		});
		jp_north.add(jl_readHomePage);
		// 分割
		jl_cutOne = new JLabel("|");
		jl_cutOne.setBounds(im_readTitle.getIconWidth() + (int) (d.width * 0.12) + 30 + 40 + 10,
				im_readTitle.getIconHeight() / 12, 15, (int) (d.height * 0.08));
		jl_cutOne.setFont(new Font("宋体", Font.BOLD, 15));
		jp_north.add(jl_cutOne);
		// 转书库标签
		jl_readBookRoom = new JLabel("书库");
		jl_readBookRoom.setBounds(im_readTitle.getIconWidth() + (int) (d.width * 0.12) + 30 + (40 + 10) + 15 + 10,
				im_readTitle.getIconHeight() / 12, 40, (int) (d.height * 0.08));
		jl_readBookRoom.setFont(new Font("宋体", Font.BOLD, 15));
		jl_readBookRoom.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jl_readBookRoom.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				new StackRoom(username,flag);
				dispose();
			}
		});
		jp_north.add(jl_readBookRoom);
		// 分割
		jl_cutTwo = new JLabel("|");
		jl_cutTwo.setBounds(im_readTitle.getIconWidth() + (int) (d.width * 0.12) + 30 + (40 + 10) * 2 + 15 + 10,
				im_readTitle.getIconHeight() / 12, 15, (int) (d.height * 0.08));
		jl_cutTwo.setFont(new Font("宋体", Font.BOLD, 15));
		jp_north.add(jl_cutTwo);
		// 转排行标签
		jl_readRank = new JLabel("排行");
		jl_readRank.setBounds(im_readTitle.getIconWidth() + (int) (d.width * 0.12) + 30 + (40 + 10) * 2 + (15 + 10) * 2,
				im_readTitle.getIconHeight() / 12, 40, (int) (d.height * 0.08));
		jl_readRank.setFont(new Font("宋体", Font.BOLD, 15));
		jl_readRank.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jl_readRank.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				 new RankingFrame(username,flag);
				 dispose();
			}
		});
		jp_north.add(jl_readRank);
		// 搜索输入框
		jt_readSelect = new JTextField("请输入");
		jt_readSelect.setBounds((int) (d.width * 0.5), (int) ((d.height * 0.08) / 3.5), 200, 30);
		jt_readSelect.setBorder(javax.swing.BorderFactory.createLineBorder(new Color(241, 241, 241)));
		jt_readSelect.setFont(new Font("宋体", Font.PLAIN, 15));
		jt_readSelect.setBackground(new Color(220, 220, 220));
		jp_north.add(jt_readSelect);
		// 搜索标签
		jl_readSelect = new JLabel();
		ImageIcon im_readSelect = new ImageIcon(NovelRead.class.getResource("readerSearch.png"));
		jl_readSelect.setIcon(im_readSelect);
		jl_readSelect.setBounds((int) (d.width * 0.67), (int) ((d.height * 0.08) * 0.35), im_readSelect.getIconWidth(),
				im_readSelect.getIconHeight());
		jl_readSelect.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jl_readSelect.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				 new SearchFrame();
			}
		});
		jp_north.add(jl_readSelect);
		// 登陆标签
		jl_readLand = new JLabel("");
		if (flag) {
			jl_readLand.setText(username);
			jl_readLand.addMouseListener(new MouseAdapter() {
			       @Override
			    public void mouseClicked(MouseEvent e) {
			    	   new Person_center(username, flag);
			    	   dispose();
			    }
			});
		 }else {
			 jl_readLand.setText("登录"); 
				jl_readLand.addMouseListener(new MouseAdapter() {
				       @Override
				    public void mouseClicked(MouseEvent e) {
				    	   new Login_Panel();
				    	   dispose();
				    }
				});
		 }
		jl_readLand.setFont(new Font("宋体", Font.BOLD, 15));
		jl_readLand.setBounds((int) (d.width * 0.78), im_readTitle.getIconHeight() / 12, 50, (int) (d.height * 0.08));
		jl_readLand.setCursor(new Cursor(Cursor.HAND_CURSOR));

		jp_north.add(jl_readLand);
		// 注册标签
		jl_readRegister = new JLabel("");
		if (flag) {
			jl_readRegister.setText("退出");
			jl_readRegister.addMouseListener(new MouseAdapter() {
			       @Override
			    public void mouseClicked(MouseEvent e) {
			          new NovelRead("", false,bookname);
			          dispose();
			    }
			});
		 }else {
			 jl_readRegister.setText("注册"); 
			 jl_readRegister.addMouseListener(new MouseAdapter() {
				       @Override
				    public void mouseClicked(MouseEvent e) {
				    	   new Register_Jpanel();
				    	   dispose();
				    }
				});
		 }
		jl_readRegister.setFont(new Font("宋体", Font.BOLD, 15));
		jl_readRegister.setBounds((int) (d.width * 0.83), im_readTitle.getIconHeight() / 12, 50,
				(int) (d.height * 0.08));
		jl_readRegister.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jp_north.add(jl_readRegister);
		// ===================================================================//
		// 中部面板
		jp_center = new JPanel();//
		jp_center.setBackground(new Color(210, 210, 210));
		int centetHight = d.height - (int) (d.height * 0.08);
		jp_center.setPreferredSize(new Dimension(0, centetHight));
		jp_center.setLayout(null);
		jp_MainScreen.add(BorderLayout.CENTER, jp_center);
		// 当前位置标签
		jl_position = new JLabel();
		jl_position.setBounds((int) (d.width * 0.11), (int) (centetHight * 0.01), d.width - (int) (d.width * 0.11), 30);
		jl_position.setFont(new Font("宋体", Font.LAYOUT_NO_LIMIT_CONTEXT, 14));
		jp_center.add(jl_position);

		// 阅读滚动面板
		js_readDisplay = new JScrollPane();
		js_readDisplay.setBounds((int) (d.width * 0.11), (int) (centetHight * 0.05), (int) (d.width * 0.7),
				centetHight - (int) (centetHight * 0.10));
		js_readDisplay.getVerticalScrollBar().setUnitIncrement(25);
//		js_readDisplay.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);	
		jp_center.add(js_readDisplay);
		// 阅读面板
		jp_readDisplay = new JPanel();	
//        jp_readDisplay.setPreferredSize(new Dimension((int) (d.width * 0.7),(centetHight - (int) (centetHight * 0.10))*2));
		jp_readDisplay.setLayout(new BorderLayout());
		js_readDisplay.getViewport().add(jp_readDisplay);
		
		// 阅读
		jt_readNovel = new JTextArea();
//		jt_readNovel.insert(", 1);		
	   	read(jt_readNovel,"E://小说项目/书库/"+bookname, pn);
	   	jl_position.setText("当前位置:"+bookname+"==>第"+(pn+1)+"章");
//		jt_readNovel.append(connect1());// 标题|内容 =======分隔线
		jt_readNovel.setLineWrap(true); 	// 激活自动换行功能
		jt_readNovel.setWrapStyleWord(true); // 不断字
		jt_readNovel.setFont(new Font("宋体", Font.BOLD, 20));
		jt_readNovel.setEditable(false);// 设置不可编辑
		jt_readNovel.setCaretPosition(0);
		jp_readDisplay.add(BorderLayout.NORTH, jt_readNovel);

		// 菜单面板
		jp_readmenu = new JPanel();
		jp_readmenu.setBounds((int) (d.width * 0.06), (int) (centetHight * 0.05), (int) (centetHight * 0.091),
				(int) (centetHight * 0.4));
		jp_readmenu.setBackground(new Color(210, 210, 210));
		jp_readmenu.setLayout(null);
		jp_center.add(jp_readmenu);
		// 菜单=====阅读目录
		jb_readCatalog = new JButton();
		ImageIcon im_readCatalog = new ImageIcon(NovelRead.class.getResource("阅读目录.png"));
		jb_readCatalog.setIcon(im_readCatalog);
		jb_readCatalog.setBounds(0, 0, im_readCatalog.getIconWidth(), im_readCatalog.getIconHeight());
		jb_readCatalog.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb_readCatalog.addActionListener(new ActionListener() {			
			@Override
			public void actionPerformed(ActionEvent e) {
				new ClickLaterFrame_click();
				dispose();
			} 
		});
		jp_readmenu.add(jb_readCatalog);
		// 菜单=====阅读设置
		jb_readSetUp = new JButton();
		ImageIcon im_readSetUp = new ImageIcon(NovelRead.class.getResource("阅读设置.png"));
		jb_readSetUp.setIcon(im_readSetUp);
		jb_readSetUp.setBounds(0, im_readCatalog.getIconWidth() - 5, im_readSetUp.getIconWidth(),
				im_readSetUp.getIconHeight());
		jb_readSetUp.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb_readSetUp.addActionListener(new ActionListener() {			
			@Override
			public void actionPerformed(ActionEvent e) {
				new ClassSet(NovelRead.this, true);
			} 
		});
		jp_readmenu.add(jb_readSetUp);
		// 菜单=====阅读书架
		jb_readStackRoom = new JButton();
		ImageIcon im_readStackRoom = new ImageIcon(NovelRead.class.getResource("阅读书架.png"));
		jb_readStackRoom.setIcon(im_readStackRoom);
		jb_readStackRoom.setBounds(0, im_readCatalog.getIconWidth() + im_readSetUp.getIconWidth() - 6,
				im_readStackRoom.getIconWidth(), im_readStackRoom.getIconHeight());
		jb_readStackRoom.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb_readStackRoom.addActionListener(new ActionListener() {			
			@Override
			public void actionPerformed(ActionEvent e) {
				if ("注册".equals(jl_readRegister.getText())) {					
	  JOptionPane.showConfirmDialog(null, "未登陆", "提示",JOptionPane.PLAIN_MESSAGE);
				}else {
					new My_bookshelf(username,flag);
					dispose();
				}	
			} 
		});
		jp_readmenu.add(jb_readStackRoom);
		// 菜单=====阅读书页
		jb_readPage = new JButton();
		ImageIcon im_readPage = new ImageIcon(NovelRead.class.getResource("阅读书页.png"));
		jb_readPage.setIcon(im_readPage);
		jb_readPage.setBounds(0,
				im_readCatalog.getIconWidth() + im_readSetUp.getIconWidth() + im_readStackRoom.getIconWidth() - 5 - 3,
				im_readPage.getIconWidth(), im_readPage.getIconHeight());
		jb_readPage.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb_readPage.addActionListener(new ActionListener() {			
			@Override
			public void actionPerformed(ActionEvent e) {
				new ClickLaterFrame_click();	
			} 
		});
		jp_readmenu.add(jb_readPage);
		// 回到顶部
		jb_readTop = new JButton();
		ImageIcon im_readTop = new ImageIcon(NovelRead.class.getResource("到顶.png"));
		jb_readTop.setIcon(im_readTop);
		jb_readTop.setBounds((int) (d.width * 0.813), centetHight - (int) (centetHight * 0.14),
				im_readTop.getIconWidth(), im_readTop.getIconHeight());
		jb_readTop.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb_readTop.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
//				   js_readDisplay.doLayout();    // 如果不是有改语句，滚动条会显示在中间			   
				    JScrollBar jscrollBar =js_readDisplay.getVerticalScrollBar();
				    if (jscrollBar != null)
				        jscrollBar.setValue(jscrollBar.getMinimum());//getMaximum()
			}
		});
		jp_center.add(jb_readTop);
		// 上一章按钮
		jb_readLastChapter = new JButton();
		ImageIcon im_readLastChapter = new ImageIcon(NovelRead.class.getResource("上一章.png"));
		jb_readLastChapter.setIcon(im_readLastChapter);
		jb_readLastChapter.setBounds((int) (d.width * 0.85), centetHight - (int) (centetHight * 0.6),
				im_readLastChapter.getIconWidth(), im_readLastChapter.getIconHeight());
		jb_readLastChapter.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb_readLastChapter.addActionListener(new ActionListener() {			
			@Override
			public void actionPerformed(ActionEvent e) {
				jt_readNovel.setText("");	
				if (pn==0) {					  
			read(jt_readNovel,"E://小说项目/书库/"+bookname,pn);	
				}else {
			digui1(jt_readNovel,"E://小说项目/书库/"+bookname,pn);		
					pn--; 
				}
			 	jl_position.setText("当前位置:"+bookname+"==>第"+(pn+1)+"章");
				jt_readNovel.setCaretPosition(0);
			}  
		});
		jp_center.add(jb_readLastChapter);
//		//下一章
		jb_readNextChapter = new JButton();
		ImageIcon im_readNextChapter = new ImageIcon(NovelRead.class.getResource("下一章.png"));
		jb_readNextChapter.setIcon(im_readNextChapter);
		jb_readNextChapter.setBounds((int) (d.width * 0.85), centetHight - (int) (centetHight * 0.5),
				im_readNextChapter.getIconWidth(), im_readNextChapter.getIconHeight());
		jb_readNextChapter.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jb_readNextChapter.addActionListener(new ActionListener() {			
			@Override
			public void actionPerformed(ActionEvent e) {
//				int i= read(jt_readNovel,"E://小说项目/书库/末日狂鼠",0);
//				剑道真章E://小说项目/书库/末日狂鼠
				jt_readNovel.setText("");	
					digui(jt_readNovel,"E://小说项目/书库/"+bookname,pn);
					pn++;
			jt_readNovel.setCaretPosition(0);
		 	jl_position.setText("当前位置:"+bookname+"==>第"+(pn+1)+"章");
			  }		
		});
		jp_center.add(jb_readNextChapter);
	
		setTitle("小说阅读");
		setSize(d);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		setVisible(true);
	}

	public static void main(String[] args) {
		try {
			//////////////////////// ---------------------------------- select Look and
			//////////////////////// Feel(下面就是要改变的地方了)
			JFrame.setDefaultLookAndFeelDecorated(true);
			UIManager.setLookAndFeel("com.jtattoo.plaf.fast.FastLookAndFeel");
			//////////////////////// ---------------------------------- start application
//			E://小说项目/书库/末日狂鼠  我在缅甸挖矿那些年 山海经
			new NovelRead("lgw",false,"末日狂鼠");
		} catch (Exception e) {
			e.printStackTrace();
		}       
	}

	  public static int digui(JTextArea jt,String pathName,int pn) {
		 return  read(jt,pathName,pn+1);	
	  }
	  public static int digui1(JTextArea jt,String pathName,int pn) {
		  return  read(jt,pathName,pn-1);	
	  }
	
	public static String[] chapter(String pathName) {
        File file=new File(pathName);
		 File[] files = file.listFiles();
		//获取第几章的数字
        int [] arr=readfile(file);
		//排序
        bubbleSort(arr);       
		String [] str=new String[arr.length];
		//章名字
		 String [] name= readfileName(file);
		 //章节路径
		String[] chapter=new String[name.length];	
		for (int i = 0; i < arr.length; i++) {	
			 if (HasDigit(files[i].getName())) {
				 str[i]=arr[i]+"";
			}else {
				str[i]=ChineseNumToArabicNumUtil.arabicNumToChineseNum(arr[i]);	
			}
			for (int j = 0; j < name.length; j++) {   	 
	      	  if (("第"+str[i]+"章"+name[j]).equals(files[j].getName())) {
				  chapter[i]="第"+str[i]+"章"+name[j];
			 }
			}
		}
		return chapter;
	}

//	"E://小说项目/书库/末日狂鼠"
   public static int read(JTextArea jt,String pathName,int pn) {
	   String[] chapter=  chapter(pathName);
		String title = "\n\t\t\t\t"+ chapter[pn].substring(0, chapter[pn].lastIndexOf("."))+"\n";
		String cutLine = "\n      ---------------------------------------------------------------------\n";
		jt.append(title);// 添加标题
		jt.append(cutLine);// 标题|内容 =======分隔线
		FileReader fr=null;
		BufferedReader br=null;
		try {
			 fr = new FileReader(pathName+"/"+chapter[pn]);
			   br=new BufferedReader(fr);
			   int c = 0;
				while((c = fr.read()) != -1){
					jt.append((char)c+"");
				}
			
		} catch (IOException e) {
			e.printStackTrace();
		}finally {
			try {
				fr.close();
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}			
		}
		return pn;
   }
   //第几章    必须有第,章  
   public static int [] readfile(File file) {
     	File[] files = file.listFiles();
     	int [] arr=new int[files.length];
     	for (int i = 0; i <files.length; i++) {
     		String name=files[i].getName();
     		String num=name.substring(name.lastIndexOf("第")+1,name.lastIndexOf("章"));
    		 arr[i]=ChineseNumToArabicNumUtil.chineseNumToArabicNum(num);
		}
     	return arr;
   }
   //章节名字
   public static String [] readfileName(File file) {
	   File[] files = file.listFiles();
	   String [] str=new String[files.length];
	   for (int i = 0; i <files.length; i++) {
		   String name=files[i].getName();
		 name=files[i].getName().substring(name.lastIndexOf("章")+1);
		   str[i]=name;
	   }
	   return str;
   }
  //排序
   public static int[] bubbleSort(int[] array) {
		if (array.length == 0)
			return array;
		for (int i = 0; i < array.length; i++)
			for (int j = 0; j < array.length - 1 - i; j++)
				if (array[j + 1] < array[j]) {
					int temp = array[j + 1];
					array[j + 1] = array[j];
					array[j] = temp;
				}
		return array;
	}
   public static boolean HasDigit(String content) {
	        boolean flag = false;
	        Pattern p = Pattern.compile(".*\\d+.*");
	        Matcher m = p.matcher(content);
	        if (m.matches()) {
	            flag = true;
	        }
	        return flag;
	    }

	class ClassSet extends JDialog {
		private static final long serialVersionUID = 1L;
		public ClassSet(Frame owner, boolean modal) {
			super(owner, modal);
			setLayout(null);
			Dimension d = getToolkit().getScreenSize();
			jl=new JLabel[2];
			String []str= {"阅读主题","正文字体"};
			for (int i = 0; i < str.length; i++) {
				jl[i]=new JLabel(str[i]);
				jl[i].setBounds((int) (d.width * 0.01),(int) (d.width * 0.01)+(int) (d.width * 0.06*i),80, 30);
				jl[i].setFont(new Font("微软雅体",Font.PLAIN, 15));
				add(jl[i]);
			}
			jl_1=new  JButton[3];
			String []str1= {"护眼","夜间","白天"};
			for (int i = 0; i < str1.length; i++) {
				jl_1[i]=new  JButton(str1[i]);
				jl_1[i].setBounds((int) (d.width * 0.055)+(int) (d.width * 0.07*i),(int) (d.width * 0.035),80, 30);
				jl_1[i].setFont(new Font("微软雅体",Font.PLAIN, 15));
				jl_1[i].setFocusable(false);		
				add(jl_1[i]);
			}
			jl_1[0].addActionListener(new ActionListener() {			
				@Override
				public void actionPerformed(ActionEvent e) {
					jt_readNovel.setBackground(new Color(180,238,180));
					jt_readNovel.setForeground(Color.BLACK);
				}
			});
			jl_1[1].addActionListener(new ActionListener() {			
				@Override
				public void actionPerformed(ActionEvent e) {
					jt_readNovel.setBackground(new Color(106,105,105));
					jt_readNovel.setForeground(Color.WHITE);
				}
			});
			jl_1[2].addActionListener(new ActionListener() {			
				@Override
				public void actionPerformed(ActionEvent e) {
					jt_readNovel.setBackground(Color.WHITE);
					jt_readNovel.setForeground(Color.BLACK);
				}
			});
			
			jl_2=new  JButton[2];
			String []str2= {"宋体","楷体"};
			for (int i = 0; i < str2.length; i++) {
				jl_2[i]=new  JButton(str2[i]);
				jl_2[i].setBounds((int) (d.width * 0.055)+(int) (d.width * 0.07*i),(int) (d.width * 0.1),80, 30);
				jl_2[i].setFont(new Font("微软雅体",Font.PLAIN, 15));
				jl_2[i].setFocusable(false);
				add(jl_2[i]);
			}

			jl_2[0].addActionListener(new ActionListener() {			
				@Override
				public void actionPerformed(ActionEvent e) {
					jt_readNovel.setFont(new Font(str2[0], Font.BOLD, 20));
				}
			});
			jl_2[1].addActionListener(new ActionListener() {			
				@Override
				public void actionPerformed(ActionEvent e) {
					jt_readNovel.setFont(new Font(str2[1], Font.BOLD, 20));
				}
			});

			setTitle("");
			setSize(400, 300);
			setLocationRelativeTo(null);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			setVisible(true);
		}
	}
}
